// SCENARIO SCRIPT

// This is the special script for your entire scenario. It contains
// special encounters and code accessable from anywhere in the scenario. it also
// contains the code that initializes important special things in the
// scenario (like shops and names and descriptions of special items).

// You can create your own states, but you should give all of them numbers greater than
// or equal to 10.

beginscenarioscript;

variables;

int time;
int ticks;
int day;
int night;
int poison;
int choice;
int i;

body;

beginstate LOAD_SCEN_STATE;
// This is the state that is called every time the scenario is loaded,
// even when a save file in the scenario is loaded. Some things that should go here:
//    Names and descriptions of special items.
//    Names and effects of custom special abilities.

init_quest(1,"See Mayor Adams.","The job advertisement you have answered said that you had to speak with Mayor Adams of Greenleaf. You should find him as soon as possible.");
init_quest(3,"Find Tovas.","Tovas, Greenleaf's mage, has gone missing. Mayor Stone thinks he may know something about his missing daughter. Find him and question him.");
init_quest(4,"Explore Tovas's Home.","Roxy wants you to explore Tovas's house for something that can find the monster. The house is in Greenleaf, and Mayor Stone can hopefully let you in.");
init_quest(5,"Find Laurina.","Now that you know that Tovas is the monster, you need to track him down and save Laurina with all haste.");
init_quest(6,"Find Steven","You met a lady in Greenleaf who has lost her friend, Steven. She wants you to find him.");


//ITEMS

init_special_item(1,"Silver Key","This simple-looking silver key is marked with a roughly scratched 'T'. It will supposedly let you into Tovas's back room in Greenleaf.");
init_special_item(2,"Bronze Key","You found this key in the tunnels under Greenleaf. Maybe it will open a door somewhere.");

//Abilities

init_special_abil(0,"Set Cut Scene Speed",10);

i = 0;
	while (i <= 3) {
		change_custom_abil_uses(i,0,1);
		i = i + 1;
		}

if(get_flag(250,5) == 0)
		set_flag(250,5,3);

break;

beginstate START_SCEN_STATE;
// This is the state that is called only once at the very beginning of 
// the scenario. Some things that should go here:
//    The stuff in shops.
//    Creating horses and boats.

//Shops

//Aries in GL - Shop 0
add_item_to_shop(0,167,1);
add_item_to_shop(0,180,2);
add_item_to_shop(0,186,17);
add_item_to_shop(0,195,3);
add_item_to_shop(0,213,1);
add_item_to_shop(0,406,5);
add_item_to_shop(0,408,7);
add_item_to_shop(0,402,6);

//Liam in Gl - Shop 1
add_item_to_shop(1,450,500);

//Rose in GL - Shop 2
add_item_to_shop(2,114,2);
add_item_to_shop(2,171,10);
add_item_to_shop(2,172,5);
add_item_to_shop(2,174,6);
add_item_to_shop(2,175,2);
add_item_to_shop(2,177,3);
add_item_to_shop(2,391,2);
add_item_to_shop(2,16,2);
add_item_to_shop(2,386,7);
add_item_to_shop(2,146,3);

//Rose in Gl - Shop 3 (Keep empty)

//Kurt in Gl - Shop 4
add_item_to_shop(4,26,5);
add_item_to_shop(4,31,1);
add_item_to_shop(4,46,3);
add_item_to_shop(4,56,2);
add_item_to_shop(4,66,1);
add_item_to_shop(4,83,3);
add_item_to_shop(4,81,500);
add_item_to_shop(4,122,1);
add_item_to_shop(4,142,2);

//Food from preston (swoon) - Shoppe 5
add_item_to_shop(5,4,500);
add_item_to_shop(5,5,15);
add_item_to_shop(5,6,15);
add_item_to_shop(5,397,500);
add_item_to_shop(5,398,15);
add_item_to_shop(5,399,5);


//set first quest to go
toggle_quest(1,1);

message_dialog("This scenario includes a special ability that allows you to set the speed of all cutscenes within the scenario. To use this feature, press _U_ and choose the _Set Cutscene Speed Ability_.","You can use this feature an infinite amount of times, and everybody in your party can use it.");

set_ticks_forward(250);
break;

beginstate START_STATE;
// This state is called every tick wherever the party is in the scenario.
// You can use the set_state


//This bit of code was taken and slightly altered from "Death at Chapman's" by Erik Westra

ticks = (get_current_tick() % 5000);
  
if((ticks > 3750) || (ticks < 250)) {
	time = night;
	set_flag(250,0,1);
	set_flag(250,3,0); //make it so day can happen next time
	} else {
		time = day;
	   	set_flag(250,0,0);
	   	set_flag(250,4,0); //Make it so night can happen next time
	}
 
if((get_current_tick() % 5000) == 250) {
	print_str("A new day dawns.");
}  

i = 0;
	while (i <= 3) {
		change_custom_abil_uses(i,0,1);
		i = i + 1;
		}

break;

// Place your own states below. Give each a number at least 10.
beginstate 10;
// Special ability to set cut scene speed ("Borrowed" from Bahs)
	change_custom_abil_uses(who_used_custom_abil(),0,1);
	
	reset_dialog();
	add_dialog_str(0,"How fast would you like the cut scenes to go?",0);
	add_dialog_choice(0,"Slowly.");
	add_dialog_choice(1,"Normally.");
	add_dialog_choice(2,"Fast!");
	choice = run_dialog(1);
	if (choice == 1)
		set_flag(250,5,4);
	if (choice == 2)
		set_flag(250,5,3);
	if (choice != 3) {
		end();
		}
	
	reset_dialog();
	add_dialog_str(0,"How fast would you like the cut scenes to go?",0);
	add_dialog_choice(0,"High speed.");
	add_dialog_choice(1,"Very high speed.");
	choice = run_dialog(1);
	if (choice == 1)
		set_flag(250,5,2);
	if (choice == 2)
		set_flag(250,5,1);
break;





